﻿using DBFirstDemo.Models;
using System;
using System.Collections.Generic;
using System.Linq;

namespace DBFirstDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("测试 EFCore");

            ////初始化数据上下文
            EFCoreDemoContext dc = new EFCoreDemoContext();

            ////ADD People & Credit
            //People p = new People()
            //{
            //    Name = "大山",
            //    Age = 22,
            //    Sex = "女"
            //};
            //dc.People.Add(p);

            //Credit c = new Credit()
            //{
            //    Course = "化学",
            //    Score = 99,
            //    PeopleId = p.Id
            //};
            //dc.Credit.Add(c);

            //dc.SaveChanges();
            //Console.ReadLine();

            //People p2 = new People()
            //{
            //    Name = "贾板枸",
            //    Age = 25,
            //    Sex = "男",
            //    Credit = new List<Credit>()
            //        { new Credit() { Course = "C++", Score = 100 },
            //          new Credit() { Course = "VF", Score = 100 } }
            //};
            //dc.People.Add(p2);

            //dc.SaveChanges();

            var t = dc.People.ToList();

            t.ForEach(x => Console.WriteLine(x.Id + "," + x.Name + "," + x.Sex));

            Console.ReadLine();
        }
    }
}
